package com.java110.mall.shop.smo.impl;


import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.shop.ShopShippingTemplateDto;
import com.java110.intf.shop.IShopShippingTemplateInnerServiceSMO;
import com.java110.po.shop.ShopShippingTemplatePo;
import com.java110.mall.shop.dao.IShopShippingTemplateServiceDao;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 运费模板内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopShippingTemplateInnerServiceSMOImpl extends BaseServiceSMO implements IShopShippingTemplateInnerServiceSMO {

    @Autowired
    private IShopShippingTemplateServiceDao shopShippingTemplateServiceDaoImpl;


    @Override
    public int saveShopShippingTemplate(@RequestBody ShopShippingTemplatePo shopShippingTemplatePo) {
        int saveFlag = 1;
        shopShippingTemplateServiceDaoImpl.saveShopShippingTemplateInfo(BeanConvertUtil.beanCovertMap(shopShippingTemplatePo));
        return saveFlag;
    }

    @Override
    public int updateShopShippingTemplate(@RequestBody ShopShippingTemplatePo shopShippingTemplatePo) {
        int saveFlag = 1;
        shopShippingTemplateServiceDaoImpl.updateShopShippingTemplateInfo(BeanConvertUtil.beanCovertMap(shopShippingTemplatePo));
        return saveFlag;
    }

    @Override
    public int deleteShopShippingTemplate(@RequestBody ShopShippingTemplatePo shopShippingTemplatePo) {
        int saveFlag = 1;
        shopShippingTemplatePo.setStatusCd("1");
        shopShippingTemplateServiceDaoImpl.updateShopShippingTemplateInfo(BeanConvertUtil.beanCovertMap(shopShippingTemplatePo));
        return saveFlag;
    }

    @Override
    public List<ShopShippingTemplateDto> queryShopShippingTemplates(@RequestBody ShopShippingTemplateDto shopShippingTemplateDto) {

        //校验是否传了 分页信息

        int page = shopShippingTemplateDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopShippingTemplateDto.setPage((page - 1) * shopShippingTemplateDto.getRow());
        }

        List<ShopShippingTemplateDto> shopShippingTemplates = BeanConvertUtil.covertBeanList(shopShippingTemplateServiceDaoImpl.getShopShippingTemplateInfo(BeanConvertUtil.beanCovertMap(shopShippingTemplateDto)), ShopShippingTemplateDto.class);

        return shopShippingTemplates;
    }


    @Override
    public int queryShopShippingTemplatesCount(@RequestBody ShopShippingTemplateDto shopShippingTemplateDto) {
        return shopShippingTemplateServiceDaoImpl.queryShopShippingTemplatesCount(BeanConvertUtil.beanCovertMap(shopShippingTemplateDto));
    }

    public IShopShippingTemplateServiceDao getShopShippingTemplateServiceDaoImpl() {
        return shopShippingTemplateServiceDaoImpl;
    }

    public void setShopShippingTemplateServiceDaoImpl(IShopShippingTemplateServiceDao shopShippingTemplateServiceDaoImpl) {
        this.shopShippingTemplateServiceDaoImpl = shopShippingTemplateServiceDaoImpl;
    }
}
